package com.tanhua.autoconfig;

import com.tanhua.autoconfig.properties.AipFaceProperties;
import com.tanhua.autoconfig.properties.HuanXinProperties;
import com.tanhua.autoconfig.properties.OssProperties;
import com.tanhua.autoconfig.properties.SmsProperties;
import com.tanhua.autoconfig.template.AipFaceTemplate;
import com.tanhua.autoconfig.template.HuanXinTemplate;
import com.tanhua.autoconfig.template.OssTemplate;
import com.tanhua.autoconfig.template.SmsTemplate;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 我愿称它为配置类
 */

@EnableConfigurationProperties({
                       SmsProperties.class,
                       OssProperties.class,
                       AipFaceProperties.class,
                       HuanXinProperties.class
                            })
public class TanhuaAutoConfiguration {
    /**
     *
     * @return  加载手机验证码发送模板类到spring容器中
     */
    @Bean
    public SmsTemplate smsTemplate(SmsProperties smsProperties) {
        return new SmsTemplate(smsProperties);
    }


    /**
     * 加载文件上传模板类到spring容器中
     * @param ossProperties
     * @return
     */
    @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties){
        return new OssTemplate(ossProperties);

    }



    @Bean
    public AipFaceTemplate aipFaceTemplate(){
        return new AipFaceTemplate();
    }


    /**创建HuanXinTemplate对象交给Spring容器管理
     *
     * @param huanXinProperties
     * @return
     */
    @Bean
    public HuanXinTemplate emTemplate(HuanXinProperties huanXinProperties){

        return new HuanXinTemplate(huanXinProperties);
    }
}
